package com.ziyun.pop.web.modules.otherAccessory.controller;

import com.ziyun.pop.modules.otherAccessory.entity.OtherAccessoryEntity;
import com.ziyun.pop.modules.otherAccessory.service.OtherAccessoryService;
import io.renren.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 其余附件
 *
 * @author gaosheng
 * @email 
 * @date 2018-09-06 09:21:40
 */
@RestController
@RequestMapping("otherAccessory/otheraccessory")
public class OtherAccessoryController {

    @Autowired
    private OtherAccessoryService otherAccessoryService;

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody OtherAccessoryEntity otherAccessory){
        otherAccessoryService.save(otherAccessory);

        return R.ok().put("id", otherAccessory.getId());
    }

    /**
     * 获得商户入库单据图片
     */
    @RequestMapping("/getMerchantReceipts/{ids}")
    public R getMerchantReceipts(@PathVariable("ids") String ids){
        List<OtherAccessoryEntity> otherAccessoryList = otherAccessoryService.getMerchantReceipts(ids);
        if(otherAccessoryList != null && otherAccessoryList.size() > 0){
            return R.ok().put("otherAccessoryList",otherAccessoryList);
        }else{
            return R.error("尚无单据,请添加");
        }
    }

    /**
     * 保存
     */
    @RequestMapping("/storeMaterialSave")
    public R storeMaterialSave(@RequestBody OtherAccessoryEntity otherAccessory){
        otherAccessoryService.save(otherAccessory);
        return R.ok().put("otherAccessory", otherAccessory);
    }
}
